Traffic & Roadblocks topic

Inspect and manage traffic incidents and user-defined roadblocks on your map and routes. This set of classes lets you read current traffic conditions, retrieve detailed preview data for incidents, add or remove persistent user roadblocks (point, path or area), and subscribe to time-based activation/expiry notifications.

  • TrafficEvent: Represents a single traffic incident or roadblock, exposing human-readable description, spatial extent (reference point, bounding box or precise area), timing (start/end), severity and classification, and transport modes affected.
  • RouteTrafficEvent: Route-specific traffic event variant that includes route-relative details such as start/end coordinates on the route, distance to destination along the route, and optional landmark representations for the start and end points.
  • TrafficService: Top-level static service for traffic operations and user roadblock management. Use it to query traffic transfer statistics and online restrictions, list or remove persistent roadblocks, request path previews for creating path-based roadblocks, add/remove point/path/area persistent roadblocks, and get the SDK-wide traffic preferences. This is the main entry point for programmatically modifying roadblocks and checking service availability.
  • TrafficPreferences: Holds SDK traffic usage configuration (online/offline/disabled). Use the preferences accessor to choose whether routing and navigation should account for live online traffic, offline data, or ignore traffic altogether; changes take effect for subsequent route calculations.
  • PersistentRoadblockListener: Event listener that delivers notifications when user-created persistent roadblocks become active or expire. Construct the listener with activation and/or expiry callbacks and register it with TrafficService to receive time-based updates.
  • TrafficParameters: Read-only model returned as detailed preview data for a traffic event. It contains additional metadata used for UI and diagnostics (identifiers, icon id, delay, time stamps, short label and transport mode).
  • UserRoadblockPathPreviewCoordinate: Small helper model used during persistent roadblock creation to step through a path preview. Create an initial instance from plain coordinates, then use TrafficService path-preview calls to obtain subsequent suggested coordinates and a preview candidate that you can use to assemble a path-based roadblock.

TrafficEvent objects provide the core incident metadata and visuals; route-aware RouteTrafficEvent instances map that information onto computed routes. Use TrafficService to read/write persistent user roadblocks, check online service availability, and fetch path previews. TrafficPreferences controls whether the SDK uses live traffic, local caches, or ignores traffic — enabling predictable routing behavior. The preview and parameter classes let you enrich UI displays with delay estimates and short descriptions, while listeners let apps react when user roadblocks change state.

Learn more about roadblocks: https://developer.magiclane.com/docs/flutter/guides/navigation/roadblocks

Classes

PersistentRoadblockListener Traffic & Roadblocks
Listener for user-defined persistent roadblock events.
RouteTrafficEvent Traffic & Roadblocks
Represents a traffic event affecting a computed Route.
TrafficEvent Traffic & Roadblocks
Represents a traffic event such as congestion, roadworks or closures.
TrafficParameters Traffic & Roadblocks
Provides additional, read-only parameters that describe a traffic event. Typical information includes estimated speed impact, expected delay, severity level, and a short descriptive label or reason for the event.
TrafficPreferences Traffic & Roadblocks
Traffic preferences for the SDK.
TrafficService Traffic & Roadblocks
Provides access to traffic-related services and user roadblock management.
UserRoadblockPathPreviewCoordinate Traffic & Roadblocks
User roadblock path preview match information.

Enums

TrafficEventClass Traffic & Roadblocks
Traffic events classes
TrafficEventImpactZone Traffic & Roadblocks
Traffic event shape
TrafficEventSeverity Traffic & Roadblocks
Traffic event severity enum.
TrafficOnlineRestrictions Traffic & Roadblocks
Restrictions which prevent online service functionality
TrafficUsage Traffic & Roadblocks
Traffic usage type.